package com.smh.demo1.a01;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**
 * @author shiminghui
 * @date 2025/4/9 17:48
 * @description: TODO
 */
@Component
@Slf4j
public class Component2 {

    @Autowired
    private ApplicationEventPublisher publisher;

    //    @PostConstruct // bean 初始化时候调用
    public void register() {
        log.debug("Component2发布事件");
        publisher.publishEvent(new MyEvent(this));
        log.debug("Component2发布事件后");
    }

}
